package com.ruoyi.web.controller.cs;

import java.util.List;
import java.util.Map;

import com.ruoyi.common.core.controller.BasicsController;
import com.ruoyi.common.core.domain.Response;
import com.ruoyi.common.core.page.ResponsePageInfo;
import com.ruoyi.cs.domain.TWar;
import com.ruoyi.cs.service.ITWarService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;

/**
 * 战令Controller
 * 
 * @author ruoyi
 * @date 2023-12-11
 */
@Api(tags = {"战令模块后台系统"})
@RestController
@RequestMapping("/cs/war")
public class TWarController extends BasicsController
{
    @Autowired
    private ITWarService tWarService;

    /**
     * 查询战令列表
     */
    @ApiOperation("查询战令列表")
    @PreAuthorize("@ss.hasPermi('system:war:list')")
    @GetMapping("/list")
    public ResponsePageInfo<TWar> list(TWar tWar)
    {
        startPage(tWar.getPageNum(),tWar.getPageSize());
        List<TWar> list = tWarService.selectTWarList(tWar);
        return toResponsePageInfo(list);
    }

    /**
     * 新增战令
     */
    @ApiOperation("新增战令")
    @PreAuthorize("@ss.hasPermi('system:war:add')")
    @Log(title = "战令", businessType = BusinessType.INSERT)
    @PostMapping
    public Response add(@Validated @RequestBody TWar tWar)
    {
        return toResponse(tWarService.insertTWar(tWar));
    }

    /**
     * 修改战令
     */
    @ApiOperation("修改战令")
    @PreAuthorize("@ss.hasPermi('system:war:edit')")
    @Log(title = "战令", businessType = BusinessType.UPDATE)
    @PutMapping
    public Response edit(@RequestBody TWar tWar)
    {
        return toResponse(tWarService.updateTWar(tWar));
    }

    /**
     * 删除战令
     */
    @ApiOperation("删除战令")
    @PreAuthorize("@ss.hasPermi('system:war:remove')")
    @Log(title = "战令", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public Response remove(@PathVariable Long[] ids)
    {
        return toResponse(tWarService.deleteTWarByIds(ids));
    }
}
